import 'package:flutter/material.dart';
import 'package:module_home/model/ISSDataEntity.dart';

class MenuItem extends StatefulWidget {
  final ISSDataEntity issDataEntity;

  const MenuItem({Key key, this.issDataEntity}) : super(key: key);

  @override
  _MenuItemState createState() => _MenuItemState();
}

class _MenuItemState extends State<MenuItem> {
  @override
  Widget build(BuildContext context) {
    return ClipRRect(
        borderRadius: BorderRadius.circular(4),
        child: Container(
            color: Colors.grey[200],
            child: Stack(
              children: [
                Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Image(
                          width: 60,
                          height: 60,
                          image: AssetImage(widget.issDataEntity.imgUrl)),
                      Padding(
                        padding: EdgeInsets.only(top: 10),
                        child: Center(
                            child: Text(widget.issDataEntity.name,
                                style: TextStyle(
                                  color: Colors.black87,
                                  fontSize: 16,
                                ))),
                      )
                    ]),
                Visibility(
                    visible: widget.issDataEntity.issValue > 0,
                    child: Positioned(
                      right: 0.0,
                      top: 0.0,
                      child: _buildImage(widget.issDataEntity.issValue),
                    ))
              ],
            )));
  }
}

Image _buildImage(int issValue) {
  switch (issValue) {
    case 1:
      return Image.asset("images/compute_icon_sign1.png",
          height: 20, width: 20);
    case 2:
      return Image.asset("images/compute_icon_sign2.png",
          height: 20, width: 20);
    case 3:
      return Image.asset("images/compute_icon_sign3.png",
          height: 20, width: 20);
    case 4:
      return Image.asset("images/compute_icon_sign4.png",
          height: 20, width: 20);
    case 5:
      return Image.asset("images/compute_icon_sign5.png",
          height: 20, width: 20);
    case 6:
      return Image.asset("images/compute_icon_sign6.png",
          height: 20, width: 20);
    default:
      return Image.asset("");
  }
}
